﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace MethodWorx.Core.Extensions
{
    public static class ArrayExtensions
    {
        public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IList src)
        {
            Dictionary<TKey, TValue> dict = new Dictionary<TKey, TValue>();

            if (src == null)
                return null;
            else
            {
                for (int i = 0; i < src.Count - 1; i += 2)
                {
                    dict.Add((TKey)src[i], (TValue)src[i]);
                }
            }

            return dict;

        }
    }
}
